<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <h1>HELLO Index</h1>

    <script src="./axios.min.js"></script>
    <script>
      const request = axios.create({
        baseURL: "http://127.0.0.1:8090/api/collections",
      });
      request.interceptors.request.use(
        (config) => {
          return config;
        },
        (error) => {
          return Promise.reject(error);
        }
      );
      // 添加响应拦截器
      request.interceptors.response.use(
        (response) => {
          return response;
        },
        (error) => {
          return Promise.reject(error);
        }
      );

      const getTodoListApi = (params) =>
        request.get("/todolist/records", {
          params,
        });
      const addTodoApi = (data) => request.post("/todolist/records", data);
      const updateTodoByIdApi = (id, data) =>
        request.patch(`/todolist/records/${id}`, data);
      const deleteTodoByIdApi = (id) =>
        request.delete(`/todolist/records/${id}`);

      getTodoListApi({
        page: 1,
        perPage: 2,
      }).then((res) => {
        console.log(res);
      });
    </script>
  </body>
</html>
